package com.lanhe.app.controller.haoka;


import com.lanhe.common.constant.Constants;
import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.core.page.TableDataInfo;
import com.lanhe.product.domain.LhHaokaProduct;
import com.lanhe.product.service.ILhHaokaProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 号卡产品表(LhHaokaProduct)表控制层
 *
 * @author zhanggl
 * @since 2023-12-25 20:19:27
 */
@RestController
@RequestMapping("/api/haoka")
public class ApiHaokaProductController extends BaseController {

	/**
	 * 服务对象
	 */
	@Resource
	private ILhHaokaProductService lhHaokaProductService;

	/**
	 * 分页查询所有数据
	 */
	@GetMapping("/list")
	public TableDataInfo list(LhHaokaProduct product) {
		startPage();
		List<LhHaokaProduct> list = lhHaokaProductService.selectHaokaProductList(product);
		for (LhHaokaProduct haokaProduct : list) {
			haokaProduct.setTypeName(Constants.HaokaType.getHaokaTypeName(haokaProduct.getType()));
		}
		return getDataTable(list);
	}

	/**
	 * 根据编号获取详细信息
	 */
	@GetMapping(value = {"/", "/{productId}"})
	public AjaxResult getInfo(@PathVariable(value = "productId") Long productId) {
		return success(lhHaokaProductService.selectHaokaProductById(productId));
	}
}

